﻿uniform sampler2D SourceMap;
uniform sampler2D StaticMap;
uniform sampler2D ColorMap;
uniform float StaticLevel;

void main(){

	vec2 uv = gl_TexCoord[0].st;

	float xo = texture2D( StaticMap,uv ).r;
	float yo = texture2D( StaticMap,uv).g;

	xo = -1.0+xo*2.0;
	yo = -1.0+yo*2.0;


	float hv = 1.0;

	float mv = 0.5f;

	float vv = abs(uv.x-mv)*0.4;

	hv *= vv;

	hv = hv < 0.0 ? 0.0 : hv;

	uv.x+=xo*StaticLevel;
	uv.y+=yo*StaticLevel;
	
	vec4 col = texture2D( ColorMap,uv);
	vec4 src = (texture2D( SourceMap, uv )*(1.0-(StaticLevel*0.35)))+(col*((StaticLevel*40.0)*hv));

	gl_FragColor.rgb = src;
	gl_FragColor.a=1.0;

}